package model;

import controller.RoomController;

import java.io.IOException;
import java.util.Random;

public class Npc extends  Figure{
    private int movecooldown;
    private Random rand = new Random();
    protected String desc;//三维
    public Npc(int con, int dex, int str, int wis, int hp, int max_hp, int nl, int max_nl, int jl, int max_jl, String name, String location,String description,int type) {
        super(con, dex, str, wis, hp, max_hp, nl, max_nl, jl, max_jl, name, location,type);
        movecooldown = 6+rand.nextInt(6);
        this.desc = description;
    }
    public void setDescription(String description) {
        this.desc = description;
    }
    public String getDescription() {
        String tmp="";
        tmp+="名字:"+getName()+"\n";
        tmp+="con:"+getCon()+"\n";
        tmp+="dex:"+getDex()+"\n";
        tmp+="str:"+getStr()+"\n";
        tmp+="wis:"+getWis()+"\n";
        tmp+="hp:"+getHp()+"/"+getMax_hp()+"\n";
        tmp+="nl:"+getNl()+"/"+getMax_nl()+"\n";
        tmp+="jl:"+getJl()+"/"+getMax_jl()+"\n";
        tmp+="人物简介:"+desc+"\n";
        return tmp;
    }

    public int getMovecooldown() {
        return movecooldown;
    }
    public void delMovecooldown() {
        movecooldown=movecooldown-rand.nextInt(4);
    }
    public String moveRandomly()  {
        Room from= RoomController.getRoom(getLocation());
        Room to=null;
        while(to==null) {
            to=from.getDes(CommonContent.getRandomDirection());
        }
        movecooldown = 6+rand.nextInt(6);
        setLocation(to.getRoomId());
        return to.getRoomId();
    }
}
